package com.zlx.xBiaoShop.controller;

import com.zlx.xBiaoShop.entity.Result;
import com.zlx.xBiaoShop.service.IMailService;
import com.zlx.xBiaoShop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName IMailController
 * @Description 邮件发送
 * @Author Edward
 * @Date 2020/11/21 15:52
 */
@RestController
@RequestMapping("/email/")
public class IMailController {
    @Autowired
    private IMailService iMailService;

    @Autowired
    private UserService userService;

    @GetMapping("send/{email}")
    public Result sendEmail(@PathVariable String email){
        if (userService.getUserByEmail(email)>0){
            iMailService.sendSimpleMail(email);
            return new Result(true,"发送验证码已成功！",null);
        }else {
            return new Result(false,"邮箱不存在，请核对后再尝试！！！",null);
        }
    }

}
